package com.nbsaas.boot.product.rest.resource;

import com.nbsaas.boot.product.api.apis.UnitApi;
import com.nbsaas.boot.product.data.entity.Unit;
import com.nbsaas.boot.product.api.domain.request.UnitRequest;
import com.nbsaas.boot.product.api.domain.response.UnitResponse;
import com.nbsaas.boot.product.api.domain.simple.UnitSimple;
import com.nbsaas.boot.product.rest.convert.UnitSimpleConvert;
import com.nbsaas.boot.product.rest.convert.UnitEntityConvert;
import com.nbsaas.boot.product.rest.convert.UnitResponseConvert;
import com.nbsaas.boot.product.data.repository.UnitRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   单位-业务接口实现
*/
@Transactional
@Service
public class UnitResource extends BaseResource<Unit,UnitResponse, UnitSimple, UnitRequest>  implements UnitApi {

    @Resource
    private UnitRepository unitRepository;

    @Override
    public JpaRepositoryImplementation<Unit, Serializable> getJpaRepository() {
        return unitRepository;
    }

    @Override
    public Function<Unit, UnitSimple> getConvertSimple() {
        return new UnitSimpleConvert();
    }

    @Override
    public Function<UnitRequest, Unit> getConvertForm() {
        return new UnitEntityConvert();
    }

    @Override
    public Function<Unit, UnitResponse> getConvertResponse() {
        return new UnitResponseConvert();
    }




}


